package com.zyh.collection;

import java.util.ArrayList;
import java.util.Collection;

/**
 * @Author zyh
 * @Date 2024/7/30
 * @Description Collection方法
 */
public class CollectionDemo1 {
    public static void main(String[] args) {
        //增加
        Collection coll=new ArrayList();
        coll.add(10);
        coll.add(20);
        coll.add(30);
        coll.add(40);
        System.out.println("coll = " + coll);//coll = [10, 20, 30, 40]
        //删除
        coll.remove(40);
        System.out.println("coll = " + coll);//coll = [10, 20, 30]
        //查询
        int size = coll.size();
        System.out.println("size = " + size);//size = 3


        Collection coll2=new ArrayList();
        coll2.add(50);
        coll2.add(60);
        coll2.add(70);
        //增加集合
        boolean add = coll.addAll(coll2);
        System.out.println("coll = " + coll);//coll = [10, 20, 30, 50, 60, 70]
        coll.removeAll(coll2);
        System.out.println("coll = " + coll);//coll = [10, 20, 30]
        boolean b = coll.containsAll(coll2);
        System.out.println("b = " + b);//b = false

    }
}
